<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	
</head>
<body>

<div id="container">
	<div>
		图书编码：<input type="text" name="code" id="code">
		<input type="button" value="按钮" id="btn">
	</div>
	<div id="info"></div>
</div>

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="ajax.js"></script>
<script type="text/javascript">
window.onload = function(){
	var btn = document.getElementById('btn');
	var info = document.getElementById('info');
	btn.onclick = function(){
		var code = document.getElementById('code').value;
		$.ajax({
			type : 'post',
			url : '8.php',
			dataType : 'json',
			data : {username:'战三',password:'123'},
			success : function(data){
				var html = '<div><span>用户名：'+data.username+'</span><span>密码：'+data.password+'</span></div>';
				info.innerHTML = html;	
			}
		});
	}

}
</script>
	
</body>
</html>